<?php
require_once 'Kanedo/View/Exception.php';
class Kanedo_View {
	
	protected $_vars = array();
	public $error = "";
	protected $viewFile = null;
	
	public function __construct($viewFile)
	{
		$this->viewFile = $viewFile;
	}
	
	public function __set($key, $val)
	{
		$this->_vars[$key] = $val;
	}
	
	public function __get($key)
	{
		return $this->_vars[$key];
	}
	
	public function renderFile()
	{
		ob_start();
		include $this->viewFile;
		$content = ob_get_contents();
		ob_end_clean();
		return $content;
	}
	
	public function getModule($name, $siteId)
	{
		/**
		 * @todo Model "Modul" einbauen
		 */
		
		
	}
	
	public function render($path)
	{
		if (file_exists($path))
		{
			ob_start();
			include $path;
			$content = ob_get_contents();
			ob_end_clean();
			echo $content;
		}else {
			throw new Kanedo_View_Exception('file_not_found');
		}
	}
	
	public function setStatus($code)
	{
		header("HTTP 1.0/ ".$code." Not Found")	;
	}
	
	public function setHeader($code)
	{
		header($code);
	}
}
?>